import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2024-09-13
 * Time: 0:18
 */
public class Test {
    /**
     *
     * @param array
     * @param x
     * @return 返回下标
     */
    public static int erFen (int []array,int x){
        int left = 0;
        int right = array.length-1;
          while(left<=right){
            int mid = (left + right ) / 2;

            if(array[mid]<x){
                left = mid +1;
            }else if(array[mid] > x){
                right = mid - 1 ;
            }else if(array[mid] == x){
                return mid;
            }
        }
        return -1;//没找到就返回-1
    }
    public static void bulpop (int []array){  //冒泡排序
        int i = array.length - 1;
        int j = 0;
        for(i = 0; i < array.length - 1;i++){
            for(j = 0;j<array.length - 1;j++){
                if(array[j]>array[j+1]){
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                }
            }
        }
    }
    public static void niZi (int arr[]){ //数组逆置
        int l = 0;
        int r = arr.length - 1;
        while(l<=r){
            int tmp = arr[r];
            arr[r] = arr[l];
            arr[l] = tmp;
            l++;
            r--;
        }

    }

    public static void main(String[] args) {
        int [][] array = {{1,2,3},{4,5,6}};
        //System.out.println(Arrays.toString(array.));
        //
        System.out.println(Arrays.deepToString(array));

        System.out.println(array.length);
        System.out.println(array[0].length);
        for (int []x:array){
            for(int y :x){
                System.out.print(y+" ");
            }
        }
        for (int i = 0;i<array.length;i++){
            for (int j = 0;j<array[0].length;j++)
                System.out.println(array[i][j]);
        }

    }



    public static void main5(String[] args){
        int [] arr = new int []{1,2,3,4,5,6,7,8};
        niZi(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void main4(String[] args) {
        int [] array = new int []{6,9,7,8,4,2,1,3};
        //Arrays.sort(array);
        //System.out.println(Arrays.toString(array));
        //System.out.println(erFen(array,4));
        bulpop(array);
        System.out.println(Arrays.toString(array));

    }
    public static void main3(String[] args) {
        int [] array = new int []{1,2,3,4,5,6};
        //int [] cop = Arrays.copyOf(array,6);
        //int [] cop = Arrays.copyOf(array,16);
        //int [] cop = Arrays.copyOfRange(array,1,3);
        //System.out.println(Arrays.toString(cop));
        int [] arr = new int [5];
        Arrays.fill(arr,10);
        System.out.println(Arrays.toString(arr));
    }
    public static void main1(String[] args) {
        int [] arry = new int[]{1,2,3,4,5};
        int length = arry.length;
        System.out.println(length);
        for (int x :arry){
            System.out.print(x+" ");
        }
        String ret =Arrays.toString(arry);
        System.out.println(ret);
    }
}
